const { pathToRegexp } = require("path-to-regexp");
let paramNames = []; //路径参数名的数组
let regexp = pathToRegexp("/post/:id", paramNames, { end: true }); // ===> /^\/post(?:\/([^\/#\?]+?))[\/#\?]?$
console.log(regexp); //
let result = "/post/100".match(regexp);
console.log(result); // ===> ['/post/100','100', index:0, input:'/user/100', groups: undefined ]
console.log(paramNames); //

/*

console.log(paramNames); 打印结果

[{

    name: 'id'
    prefix: '/',
    suffix: '',
    pattern: '[^\\/#\\?]+?',
    modifier: ''

}]



*/
